<template>
    <div>
        <city-head></city-head>
        <city-search :cities="cities"></city-search>
        <city-list :hotCities="hotCities" :cities="cities" :letter="letter"></city-list>
        <city-alphabet :cities="cities" @updateLetter="handleUpdateLetter"></city-alphabet>
    </div>
</template>

<script>
    import CityHead from '@/pages/city/components/Head'
    import CitySearch from '@/pages/city/components/search'
    import CityList from '@/pages/city/components/list'
    import CityAlphabet from '@/pages/city/components/alphabet'
    import axios from 'axios'
    export default {
        name: "City",
        components: {
            CityHead,
            CitySearch,
            CityList,
            CityAlphabet
        },
        data() {
            return {
                cities:{},
                hotCities:[],
                letter:''
            }
        },
        methods: {
            getCityInfo() {
                axios.get('api/city.json').then(this.getCityInfoSucc)
            },
            getCityInfoSucc(res){
                if(res.data.ret){
                    const data=res.data.data;
                    this.cities=data.cities;
                    this.hotCities=data.hotCities;
                }
            },
            handleUpdateLetter(letter){
                this.letter=letter;
            }
        },
        mounted() {
            this.getCityInfo();
        }
    }
</script>

<style scoped lang="stylus">

</style>